package pl.edu.amu.wmi.kino.visualjavafx.model.animation.transformations;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.interpolators.Interpolation;
import pl.edu.amu.wmi.kino.visualjavafx.model.objects.VisualObject;

// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
// #[regen=yes,id=DCE.DBDB978B-C3C3-251F-CA4A-9578D6BF91B9]
// </editor-fold>
/**
 * Default values for all paramters are Double.NaN, set only those you really wish to change,
 * all unchanged parameters will NOT be generated in javafx code and it will work just fine
 * @author Admin
 */
public class Scale implements Transformation ,java.io.Serializable{

    // Code block for changeListeners support start
    protected PropertyChangeSupport propertySupport= new PropertyChangeSupport(this);
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.addPropertyChangeListener(listener);
    }
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.removePropertyChangeListener(listener);
    }
    // Code block for changeListeners support end

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.D0BE583C-BCDA-D38F-1FD0-B4E52523CC71]
    // </editor-fold> 
    public Scale () {
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.9039298C-4898-764C-5C6E-CEAA5E917D34]
    // </editor-fold> 
    @Override
    public Interpolation getInterpolation () {
        return this.myInterpolations[0];
    }

    @Override
    public Interpolation[] getInterpolations() {
        return this.myInterpolations;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.4D9AD2FE-9A59-73AA-865A-101410EF5499]
    // </editor-fold> 
    @Override
    public void setInterpolation (Interpolation i) {
        Interpolation oldVal = this.myInterpolations[0];
        this.myInterpolations[0]=i;
        this.myInterpolations[1]=i;
        propertySupport.firePropertyChange( "Inerpolation" , oldVal, i);
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.F2E8BED7-0DBA-F934-C62F-6A5CB210764D]
    // </editor-fold> 
    @Override
    public VisualObject transform (double howMuch, VisualObject transformable,VisualObject orginalTransformedObject) {
        double sizeX = this.getInterpolations()[0].getValue(howMuch,
                transformable.getSizeH(), this.destinedHSize);
        double sizeY = this.getInterpolations()[1].getValue(howMuch, 
                transformable.getSizeV(), this.destinedVSize);
        transformable.setSizeH(sizeX);
        transformable.setSizeV(sizeY);
        return transformable;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.DEC2C47B-2864-825E-41EA-B8A852D4BBAF]
    // </editor-fold> 
    public double getVDestinedSize () {
        return this.destinedVSize;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.7073A477-63C1-DDEF-841F-6FCE1F9E195D]
    // </editor-fold> 
    public void setVDestinedSize (double val) {
        double oldVal = this.destinedVSize;
        this.destinedVSize=val;
        propertySupport.firePropertyChange( "destinedVSize" , oldVal, val);
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.B71EED80-1A73-F9EB-80A5-935980665F82]
    // </editor-fold> 
    public double getHDestinedSize () {
        return this.destinedHSize;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.42EA1319-D245-BED5-3536-42433D965FCB]
    // </editor-fold> 
    public void setHDestinedSize (double val) {
        double oldVal = this.destinedHSize;
        this.destinedHSize=val;
        propertySupport.firePropertyChange( "destinedHSize" , oldVal, val);
    }

    private Interpolation[] myInterpolations=new Interpolation[2];
    private double destinedHSize=Double.NaN;
    private double destinedVSize=Double.NaN;



}

